<?php
/**
 * Created by PhpStorm.
 * User: 技术员专用
 * Date: 2019/3/11
 * Time: 16:26
 */
class A{
    static function httpServer($request, $response){
//        $getInfo=$request->get;//获取get参数，$_GET获取参数是无效的
        $response->cookie('cok','1111',time()+60);//设置cookie，需要在end之前
        $response->end("<h1>Hello Swoole. #".rand(1000, 9999)."</h1>");
    }
}
$http=new swoole_http_server('0.0.0.0',8811);
$http->set([
    'document_root' => '/www/wwwroot/live/data',
    'enable_static_handler' => true,
]);
//$http->on('request','A::httpServer');
//$http->on('request',['A','httpServer']);

$http->on('request',function ($request, $response){
    $response->cookie('cok','1111',time()+60);//设置cookie，需要在end之前
    $response->end("<h1>Hello Swoole. #".rand(1000, 9999)."</h1>");
});
$http->start();